package cn.live.kyle.questionnaire.question;

import org.w3c.dom.Element;

public class QuestionItemFactory {
	public static QuestionItem getQuestionItem(Element element,
			QuestionPage page) {
		String tagName = element.getAttribute(QuestionDomParser.ATTR_TYPE);
		if (tagName.equals(QuestionDomParser.ATTR_TYPE_TEXT)) {
			return new QuestionText(element, page);
		} else if (tagName.equals(QuestionDomParser.ATTR_TYPE_RADIO)) {
			return new QuestionRadio(element, page);
		} else if (tagName.equals(QuestionDomParser.ATTR_TYPE_MULTISELECT)) {
			return new QuestionMultiselect(element, page);
		} else if (tagName.equals(QuestionDomParser.ATTR_TYPE_DATE)) {
			return new QuestionDate(element, page);
		}

		return null;
	}
}
